import axios from '@/utils/api'



// 查看所有的领养信息
const gitshop = (page) => {
    return axios.get("http://localhost:3000/api/allShop", { params: { page: page } })
}


//添加数据
const addshop = (formData) => {
    return axios.postForm("http://localhost:3000/api/addShop", formData)
}

// 修改
const updateshop = (formData) => {
    return axios.postForm("http://localhost:3000/api/updateShop", formData)
}

//  删除
const delshop = (id) => {
    return axios.post("http://localhost:3000/api/delShop", { id })
}



// 筛选
const selectshop = (name = undefined, category = undefined, brand = undefined, price = undefined, site = undefined, coos = undefined, page = 1) => {
    const query = { name, category, brand, price, site, coos };
    const filterQuery = Object.fromEntries(
        Object.entries(query).filter(([key, value]) => value)
    );
    return axios.post("http://localhost:3000/api/selectShop", { filterQuery, page })
}





export { gitshop, addshop, updateshop, delshop, selectshop }



